<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./lib/vue.js"></script>
</head>

<body>
    <div id="app">
        <input type="text" v-model='firstName'> +
        <input type="text" v-model='lastName'> =
        <input type="text" v-model='fullName'>
    </div>
</body>
<script>
    var vm = new Vue({
        el: '#app',
        data: {
            firstName: '',
            lastName: '',
            fullName: ''
        },
        methods: {
            getFullName() {
                this.fullName = this.firstName + '-' + this.lastName;
            }
        },
        watch: {
            // 使用这个属性可以监视data中指定数据的变化,然后触发这个watch中对应的function处理函数
            firstName: function (newValue, oldValue) {
                console.log(this.firstName);
                console.log(newValue + '===' + oldValue);

                this.fullName = this.firstName + '-' + this.lastName;
            },
            lastName: function () {
                this.fullName = this.firstName + '-' + this.lastName;
            }
        }
    });
</script>

</html>